home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 36
/
PC Gamer IT CD 36 2-2.iso
/
VIGDEMO
/
data1.cab
/
Assets
/
scripts
/
rocket_launcher.e
< prev
next >
Wrap
Text File
|
1998-09-21
|
6KB
|
778 lines
int Initialize(string type)
{
global int state;
global real repeatTime = 1.00;
global int gRocket = 0;
global string gProjType = "rocket";
global int gGravity = 0;
global int gBulletCount = 20;
global int gClipSize = 5;
global int gStartSound = 7;
global int gProgressSound = 18;
global int gEndSound = -1;
global int gReloadSound = -1;
global real gLaunchVel = 20.0;
global real gMass = 5.0;
Reset("dummy");
return 0;
}
int startsound(string soundname)
{
gStartSound = GetSoundIndex(soundname);
}
int endsound(string soundname)
{
gEndSound = GetSoundIndex(soundname);
}
int progresssound(string soundname)
{
gProgressSound = GetSoundIndex(soundname);
}
int reloadsound(string soundname)
{
gReloadSound = GetSoundIndex(soundname);
}
int destroy (string dummy)
{
if (gRocket != 0)
{
Remove(gRocket,0);
gRocket = 0;
}
}
int projtype(string str)
{
gProjType = str;
}
int Reset(string dummy)
{
state = 1;
wakeupTime = 0.2;
gRocket = 0;
SetCollidableProperties(thisObject,gGravity,0);
SetStyle(thisObject,2);
SetScale(thisObject,2.0);
gBulletCount = gClipSize;
return 0;
}
int SerializeClean(string str)
{
state = 1;
gRocket = 0;
wakeupTime = 0.2;
}
int repeattime(string str)
{
repeatTime = Str2Real(str);
return 0;
}
int addammo(string count)
{
int value = Str2Int(count);
gBulletCount = gBulletCount + value;
}
int clipsize(string count)
{
gClipSize = Str2Int(count);
gBulletCount = gClipSize;
}
int GetMaxAmmo(string dummy)
{
ReturnValue(thisObject, gClipSize);
}
int reload(string count)
{
int add;
add = Str2Int(count);
if (add > 0)
{
PlaySound(thisObject,gReloadSound);
gBulletCount += add;
}
state = 2;
}
int AmmoCount(string dum)
{
ReturnValue(thisObject,gBulletCount);
}
int CanHitTarget(string dum)
{
int ret;
if (CheckObjectPath(gRocket) == 1)
ret = 0;
else
ret = 1;
ReturnValue(thisObject,ret);
return ret;
}
int Drop(string dummy)
{
int returnBullet;
SetScale(thisObject,2.0);
if (gRocket)
SetScale(gRocket,2.0);
SetCollidableProperties(thisObject,gGravity,0);
SetStyle(thisObject,2);
ReturnValue(thisObject,0);
}
int Draw(string ammoCount)
{
if (gRocket != 0)
SetStyle(gRocket,3);
gBulletCount = Str2Int(ammoCount);
}
int Pickup(string dummy)
{
SetRocketToParentStyle(0);
ReturnValue(thisObject,gBulletCount);
gBulletCount = 0;
}
int Holster(string dummy)
{
if (gRocket != 0)
SetStyle(gRocket,4);
ReturnValue(thisObject,gBulletCount);
gBulletCount = 0;
}
int gravity(string flag)
{
int value;
value = Str2Int(flag);
gGravity = value;
SetCollidableProperties(thisObject,gGravity,0);
}
int Colliders(string dummy)
{
map::iterator ix;
map objInList;
int value;
objInList = Collisions(thisObject,0,1,0);
for (ix = begin(objInList) ;ix != end(objInList); ++ix)
{
value = AddObjectTo(first(dereference(ix)),thisObject);
if (value != 0)
{
SetScale(thisObject,1.0);
break;
}
}
return 0;
}
int GetFireTime(string dummy)
{
ReturnValueReal(thisObject,repeatTime);
return 0;
}
int SetBulletCount(int count)
{
gBulletCount = count;
}
int FireFulfill(int hit)
{
real time ;
time = GetTime(thisObject);
state = 1;
Animate(thisObject,1,"fire");
ParentFire(thisObject);
Launch(thisObject,gRocket,1,gLaunchVel,1.0,1);
gRocket = 0;
wakeupTime = time + repeatTime;
}
int Fire(int flag)
{
real time ;
time = GetTime(thisObject);
int result = 0;
if (UnlimitedAmmo(thisObject) == 1)
gBulletCount = gClipSize;
if (state == 2)
{
if (gBulletCount >= 1)
{
gBulletCount--;
FireSaveInfo(thisObject,1,gBulletCount,gMass);
FireCommand(thisObject);
result = 1;
}
else
{
state = 4;
ParentReloadCommand(thisObject);
}
}
ReturnValue(thisObject,result);
return result;
}
int SetRocketToParentStyle(int hello)
{
if (gRocket != 0)
{
int result;
result = IsVisible(thisObject);
if (result !=0)
SetStyle(gRocket,3);
else
SetStyle(gRocket,4);
SetToParentScale(gRocket);
}
}
int SetBulletCount(int count)
{
gBulletCount = count;
}
int TimedEvent(int input)
{
int time;
time = GetTime(thisObject);
switch (state)
{
case 0:
break;
case 1:
gRocket = MakeProjectile(thisObject,gProjType);
if (gRocket == 0)
{
wakeupTime = time + repeatTime;
print("can't make a rocket");
return 0;
}
else
{
SetRocketToParentStyle(0);
}
Animate(thisObject,0,"fire");
PlaySound(thisObject,gEndSound);
state = 2;
wakeupTime = -1.0;
break;
default:
break;
}
return 0;
}
int FlushDied(int brain)
{
if (gRocket == brain)
{
gRocket = 0;
state = 1;
}
}